package cn.craftyun.yunexam.config;

import cn.craftyun.yunexam.interceptor.AdminLoginUser;
import cn.craftyun.yunexam.interceptor.LoginUser;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private LoginUser loginUser;
    @Resource
    private AdminLoginUser adminLoginUser;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginUser)
                .addPathPatterns("/exam/**")
                .addPathPatterns("/user/getInfo")
                .excludePathPatterns("/exam/getExam");
        registry.addInterceptor(adminLoginUser)
                .addPathPatterns("/admin/**");
    }
}
